#include "../../include/httpLib.hpp"
using namespace std;

// 测试服务器在达到性能瓶颈导致服务提前释放，是否会导致服务器出现段错误，还是正常处理当前事件之后直接释放

int main()
{
    for (int i = 0; i < 10; ++i)
    {
        pid_t id = fork();
        if (id == 0)
        {
            tcpSocket c;
            if (!c.createClient("127.0.0.1", 8080))
            {
                lg(Error, "create client error");
                return 1;
            }
            while (true)
            {
                std::string req = "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 0\r\n\r\n";
                while (1)
                {
                    assert(c.send(req, false) != -1);
                    char buf[1024] = { 0 };
                    string ans;
                    ssize_t n = c.recv(&ans, 1024, false);
                    cout << ans << endl;
                    sleep(1);
                }
            }
        }
    }
    while (true) sleep(1);
    return 0;
}